//
//  TableViewCell.m
//  XHAdSDKTest
//
//  Created by 陈俭红 on 2022/1/10.
//

#import "TableViewCell.h"

@interface TableViewCell ()
@property (nonatomic, strong)UILabel * titleLabel;
@property (nonatomic, strong)UIView * segView;
@end

@implementation TableViewCell

//MARK: Cycle Methods
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addAllViews];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    self.titleLabel.frame = CGRectMake(15, 0, 200, self.frame.size.height);
    self.segView.frame = CGRectMake(0, self.frame.size.height - 0.5, self.frame.size.width, 0.5);
}

//MARK: Custom Methods
- (void)addAllViews{
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.segView];
}



//MARK: Setter Methods
- (void)setDic:(NSDictionary *)dic{
    _dic = dic;
    
    self.titleLabel.text = dic[@"title"];
}

//MARK: Getter Methods
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.font = [UIFont systemFontOfSize:15];
        _titleLabel.textColor = [UIColor blackColor];
    }
    return _titleLabel;
}

- (UIView *)segView{
    if (!_segView) {
        _segView = [UIView new];
        _segView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    }
    return _segView;
}
@end
